-- @Author: baidwwy
-- @Date:   2018-06-12 07:07:02
-- @Last Modified by:   baidwwy
-- @Last Modified time: 2018-06-12 09:27:26

require "gge函数"
require "lfs"
snippet = [=[
<snippet>
    <content><![CDATA[%s(${1:%s})]]></content>
    <tabTrigger>%s</tabTrigger>
    <scope>source.lua</scope>
    <description>%s</description>
</snippet>
]=]
path = "I:/GGELUA2018/GGELUA/编辑器/Data/Packages/Lua/ggesnippet/gui/%s.sublime-snippet"
function getpathes(rootpath, pathes)
    pathes = pathes or {}
    for entry in lfs.dir(rootpath) do
        if entry ~= '.' and entry ~= '..' then
            local path = rootpath .. '\\' .. entry
            local attr = lfs.attributes(path)
            assert(type(attr) == 'table')

            if attr.mode == 'directory' then
                getpathes(path, pathes)
            else
                table.insert(pathes, path)
            end
        end
    end
    return pathes
end

for i,v in ipairs(getpathes("I:/GGELUA2018/GGELUA/脚本/游戏端/gge界面")) do
    code = __gge.utf8toansi(__gge.readfile(v))
    for a,b in string.gmatch(code, 'function%s+.-:(.-)%((.-)%)') do
        if a~= '初始化' and a[1] ~= 95 then
            --print(a,b,gge.取拼音首字母(a),a)
            --print(snippet:format(a,b,gge.取拼音首字母(a),a))
            __gge.writefile(path:format(a),__gge.ansitoutf8(snippet:format(a,b,gge.取拼音首字母(a),a)))
        end
    end
end
